//
//  sendPersonHeadImage.m
//  tcpoctest
//
//  Created by gump on 5/23/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "sendPersonHeadImage.h"
#import "bigHeadImageDataSource.h"

@implementation sendPersonHeadImage

-(void)SendHeadImageP
{
    if (![self CheckLogin]) {
        return;
    }
    
    if ([DataControl shareControl].bigHIDS.UserBigImage == nil
        || [DataControl shareControl].iImage == nil) {
        return;
    }
    
    NSData *imageData = UIImageJPEGRepresentation([DataControl shareControl].iImage, JPG_COMPRESS_RATE);
    int imagelength = [imageData length];
    NSData *bigimagedata = UIImageJPEGRepresentation([DataControl shareControl].bigHIDS.UserBigImage, JPG_COMPRESS_RATE);
    int bigimagelength = [bigimagedata length];
    
    int l = CHAR_PL * 2 + imagelength + INT_PL * 3 + bigimagelength;
    
    [self initDataByLength:l];
    
    [sb WriteInt:imagelength withNTT:NTT_SMALL2BIG];
    [sb WriteData:(char *)[imageData bytes] withLength:imagelength];
    
    [sb WriteInt:bigimagelength withNTT:NTT_SMALL2BIG];
    [sb WriteData:(char *)[bigimagedata bytes] withLength:bigimagelength];
    
    [self Package];
}

@end
